package com.um.jdy.ykc.command;

import com.um.jdy.ykc.utils.RadixsUtil;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import lombok.Data;

/**
 * 计费模型验证请求应答（运营平台->充电桩）
 *
 * @author 甘天伟
 * @since 2022/6/27
 * 版权所有 广州优匠科技有限公司
 */
@Data
public class Cmd06VerifyPriceModelResponse extends YkcCommand {

    /**
     * 桩编码：7个字节
     */
    private String code;

    /**
     * 计费模型编号：2个字节
     */
    private String feeMode;

    /**
     * 验证结果：1个字节,0x00 桩计费模型与平台一致 0x01 桩计费模型与平台不一致
     */
    private int verifyResult;

    public Cmd06VerifyPriceModelResponse(int serial,String code,String feeMode,int verifyResult) {
        super();

        this.serial = serial;
        this.encFlag = RadixsUtil.hexToInteger("00");
        this.command = RadixsUtil.hexToInteger("06");

        this.code = code;
        this.feeMode = feeMode;
        this.verifyResult = verifyResult;

        byte[] _code = RadixsUtil.hexToBytes(code);
        byte[] _feeMode = RadixsUtil.hexToBytes(feeMode);


        ByteBuf buff = Unpooled.buffer();
        buff.writeBytes(fillZeroBytes(_code,7 - _code.length));
        buff.writeBytes(_feeMode);
        buff.writeByte(verifyResult);

        this.data = new byte[buff.readableBytes()];
        buff.readBytes(data);
        buff.release();

        postConstruct();
    }
}
